<?php
require "../../core/core.php";
$mod = "patient";
$table = "patient_".$user_hospital_id;

include('ypzy/functions/global.func.php');
$swr=$_POST['ti'];
$tables=$_POST['tables'];
$ty=$_POST['ty'];
$btime=$_POST['btime'];
$etime=$_POST['etime'];
$status=$_POST['status'];
if($ty=="order_date"){$ty="到院时间";}else if($ty=="addtime"){$ty="添加时间";}else{$ty="未选";}
if($status=="come"){$status="已到";}else if($status=="not"){$status="未到";}else{$status="不限";}

$data = $db->query("select $swr from $tables");
foreach($data as $k=>$v){
   foreach($v as $kk=>$vv){
     $ddd[$k][$kk]=iconv("gb2312","utf-8",$vv); 	    
	   }
 	}
global $debug_mode;
global $db, $uid, $username, $table;

$op_data="时间类型:".$ty."<br>导出时间：".$btime."一".$etime."<br>是否到院:".$status."<br>导出字段：".$swr;
$op_data=iconv("UTF-8","gbk//TRANSLIT",$op_data);
$title=iconv("UTF-8","gbk//TRANSLIT","一键导出数据");
$pagename=$_SERVER["REQUEST_URI"];
$table_name = $table_name ? $table_name : ("(".$table.")");
$ip= get_ip();
$addtime= time();
$mo_leixing=$_SERVER['HTTP_USER_AGENT'];
$mo_os = moos();
$mo_ip= getCity(get_ip());
//$log->add("export", "一键导出: ".implode("、", $del_name), $op_data, $table,'',$mo_leixing,$mo_os);
$db->query("insert into sys_log set type='export', title='$title', data='$op_data',pagename='$pagename',table_name='$table_name',username='$username',uid='$uid',ip='$ip',addtime='$addtime',mo_leixing='$mo_leixing',mo_os='$mo_os',mo_ip='$mo_ip'");

$ttt=$_POST['ttt'];
$cc=explode(",",$ttt);
$bbb=array_filter($cc);
$wheress=$_POST['wheress'];
$wheress=explode(",",$wheress);
$wheress=array_filter($wheress);
$info=array_combine($wheress,$bbb);
foreach($info as $tt=>$bb){
	 $infos[$tt]=iconv("gb2312","utf-8",$bb); 	
	}
export_to_excel($ddd,Report,$infos);








?>